<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 100px;
        }
    </style>
</head>
<body>
    <div id="box"></div>

<script>
    var box = document.getElementById("box");
    box.onmousemove = function (event) {
        var e = event || window.event;

        var x = event.clientX - box.offsetLeft;
        var y = event.clientY - box.offsetTop;
        // console.log(x, y);

        box.innerText = '(x: ' + x +', y:' + y +')';
    }
</script>
</body>
</html>